/*
* $Id: std.h 2 2009-12-23 13:58:02Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2009 by Volokitin Alexey
* All rights reserved
*
*/
#ifndef __STD_H__
#define __STD_H__

#include <string>

namespace std
{
#if	defined(_UNICODE)
	typedef wstring xstring;
#else
	typedef string xstring;
#endif
	class tstring : public xstring
	{
	public:
		tstring()
			: xstring(){}
		tstring(const tstring& strSource)
			: xstring(strSource){}
		tstring(tstring::const_iterator begin, tstring::const_iterator end)
			: xstring(begin, end){}
		tstring(const xstring::_Myt& strSource)
			: xstring(strSource){}
#if	defined(_UNICODE)
		tstring(const wchar_t* pSource)
#else
		tstring(const char* pSource)
#endif
			: xstring(pSource){}
#if	defined(_UNICODE)
		tstring(const wchar_t* pSource, size_t size)
#else
		tstring(const char* pSource, size_t size)
#endif
			: xstring(pSource, size){}
		bool operator < (const tstring& strComp) const
		{
			return _tcscoll(c_str(), strComp.c_str()) < 0;
		}
		bool operator > (const tstring& strComp) const
		{
			return _tcscoll(c_str(), strComp.c_str()) > 0;
		}
	};

	template<class _FwdIt, class _Ty, class _Pr>
	inline _FwdIt LowerBound(_FwdIt _First, _FwdIt _Last, const _Ty& _Val, _Pr _Pred)
	{
		__w64 int nCount =  _Last - _First;
		for (; 0 < nCount; )
		{
			__w64 int nCount2 = nCount / 2;
			_FwdIt _Mid = _First + nCount2;
			if (_Pred(*_Mid, _Val))
				_First = ++_Mid, nCount -= nCount2 + 1;
			else
				nCount = nCount2;
		}
		return (_First);
	}
}

#endif /* __STD_H__ */